import { Injectable } from '@angular/core';

@Injectable()
export class StorageService {

  constructor() { }

  setLocal(key, val){
    localStorage.setItem(key, val);
  }

  setLocalObject(key, obj){
    localStorage.setItem(key, JSON.stringify(obj));
  }

  getLocal(key){
    return localStorage.getItem(key);
  }

  getLocalObject(key){
    return JSON.parse(localStorage.getItem(key));
  }

  removeLocal(key){
    localStorage.removeItem(key);
  }

  setSession(key, val){
    sessionStorage.setItem(key, val);
  }

  setSessionObject(key, obj){
    sessionStorage.setItem(key, JSON.stringify(obj));
  }

  getSession(key){
    return sessionStorage.getItem(key);
  }

  getSessionObject(key){
    return JSON.parse(sessionStorage.getItem(key));
  }

  removeSession(key){
    sessionStorage.removeItem(key);
  }

}
